﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="VerPost.aspx.cs" Inherits="Pages_VerPost"
    MasterPageFile="~/Pages/MasterPage.master" %>

<asp:Content ID="contHead" runat="server" ContentPlaceHolderID="cphHead">
    <link href="../css/Home.css" rel="stylesheet" type="text/css" />
    <link href="../css/VerPost.css" rel="stylesheet" type="text/css" />
    <script src="../js/HomeAndPerfil.js" type="text/javascript"></script>
    <script src="../js/Postear.js" type="text/javascript"></script>
    <script src="../js/FacebookIntegration.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="contBody" runat="server" ContentPlaceHolderID="cphContenido">
    <script type="text/javascript" src="../js/Comentar.js"></script>
    <div class="container_12">
        <script src="../js/Post.js" type="text/javascript"></script>
        <script type="text/javascript">
        setIdLogueado(<%=Session["IdUsuario"]%>);
            $(document).ready(function () {

                traerUsuario(getParameterByName('usuarioId'));

                if(getParameterByName('usuarioId') != '<%=Session["IdUsuario"]%>')
                    $("#ControlsEditPost").empty();

                var PostId = getParameterByName('postId');
                $('<div class="caja-comentar">' +
                    '<textarea id="comentarPostId" class="texto-comentar vacio" >' + ESCRIBI + '</textarea>' +
                    '<input type="button" class="comentar butoon recuadro" value="Comentar" onclick="Comentar(' + '<%=Session["IdUsuario"]%>' + ', ' + PostId + ')" />' +
                  '</div>').appendTo('#comentariosPost');

            });
        </script>
        <script type="text/javascript">
            function getParameterByName(name) {
                name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
                var regexS = "[\\?&]" + name + "=([^&#]*)";
                var regex = new RegExp(regexS);
                var results = regex.exec(window.location.href);
                if (results == null)
                    return "";
                else

                    return decodeURIComponent(results[1].replace(/\+/g, " "));
            }

            function dibujarComentarios(comentarios) {


                $.each(comentarios, function (index, comentario) {

                    $(htmlComentario(comentario, false)).appendTo('#comentarios');
                });
            }

            function dibujarPost(post) {
                $('#titulo-post').append(post.Titulo);
                $('#el-post').append(post.Contenido);
                $('#bancan').attr('cant', post.CantidadBancan);
                $('#bancan').append((post.CantidadBancan > 0 ? ('<div><a onclick="verBancadoresPost(' + post.Id + ')">' + post.CantidadBancan + (post.CantidadBancan > 1 ? ' usuarios bancan este post</a></div>' : ' usuario banca este post</a></div>')) : ''));
                $('#bancar').append((post.PermitirBancar == "True" ? ('<div id="bancarPost' + post.Id + '" class="bancar"><a onclick="bancarPost(' + post.Id + ');">bancar post</a></div>') : '<div class="bancando">bancas este post<div>'));
                dibujarComentarios(post.Comentarios);
            }



            var wsPost = new Post("../servicios/Post.asmx/BuscarPost");

            wsPost.buscarPost(<%=Session["IdUsuario"]%>,getParameterByName('postId'), dibujarPost);
        
        
        </script>
        <div id="scroll" class="grid_12 separacion">
        </div>
        <br />
        <div class="grid_12 omega">
            <div style="height: 100%;" class="grid_3">
                <div id="Perfil" class="alpha grid_3 ContenidoPagina">
                    <div id="fotoPerfilUsuario">
                    </div>
                    <div id="nombreUsuario">
                    </div>
                    <div id="tipoUsuario">
                    </div>
                </div>
                <div id="ControlsEditPost" class="grid_3">
                    <br />
                    <input id="Editar" type="button" value="Editar post" onclick="EditarPost(getParameterByName('postId'))" class ="butoon recuadro" />
                    <input id="Elimiar" type="button" value="Eliminar post" onclick="EliminarPost(getParameterByName('postId'))" class ="butoon recuadro"/>
                </div>
            </div>
            
            <div class="newPosts" id="post">
                <div id="socialFooter" class="socialFooter">
                    <a href="https://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="matiDSalerno" data-lang="es">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
                    <div class="fb-like" action="like" send="false" data-layout="button_count" data-width="450"></div>
                </div>
                <div id="titulo-post" class="caja-post alpha ContenidoPagina">
                </div>
                <div id="el-post" class="post alpha ContenidoPagina">
                </div>
                <br />
                <br />
                <div class="clear">
                </div>
                <div cant="0" id="bancan"></div>
                <div id="bancar"></div>
                <div id="comentarios" class="classComenatrioVerPost">
                </div>
                <div id="bancadores" class="contenedorBancadores"><div id="cerrarBancadores" onclick="cerrarBancadores();"><b>x</b></div></div>												
                <div id="comentariosPost" class="classComenatrioVerPost">
                </div>
            </div>
        </div>
    </div>
</asp:Content>
